package com.xzy.domain;

import lombok.Data;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * 购物车类
 *
 * @param <T>此泛型为购物车商品类型
 */
@Data
public class Cart<T> {
    /**
     * 商品总价
     */
    private BigDecimal totalPrice = new BigDecimal(0);
    /**
     * 商品总数
     */
    private int totalCount;
    /**
     * 商品项表
     */
    private Map<Integer,T> items = new HashMap<>();

    @Override
    public String toString() {
        return "Cart{" +
                "totalPrice=" + totalPrice +
                ", totalCount=" + totalCount +
                ", items=" + items +
                '}';
    }

    public BigDecimal getTotalPrice() {
        return totalPrice;
    }

    public int getTotalCount() {
        return totalCount;
    }
}
